<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
	prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
	prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
	prefix="logic"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles"
	prefix="tiles"%>
<%@ taglib uri="/WEB-INF/navigationTag.tld" prefix="nav"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
	<html:base />


	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">


	<script type="text/javascript" src="/agvWeb/js/grid.locale-es.js"></script>
	<script type="text/javascript"
		src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-3.8.2/js/jquery.jqGrid.min.js"></script>

	<script type="text/javascript">
    //<![CDATA[
        $(document).ready(function () {


			$.ajax({        
				type: "POST",        
				url: "/agvWeb/rpt.do?method=obtenerDatosGrid",        
				dataType: "json",        
				success: function(result){             
					colN = result.colNames;             
					colM = result.colModel;              
					
						$("#list").jqGrid({                 
							url: '/agvWeb/rpt.do?method=buscarDatosCatalogo',                 
							datatype: 'json',                 
							mtype: 'POST',
							cache: false,                 
							colNames:colN,                 
							colModel: colM,                 
			                pager: '#pager',
			                rowNum: 10,
			                width: 1210,
			                rowList: [5, 10, 20, 50],
			                viewrecords: true,
							multiselect: true,
							multiboxonly: true,
			                gridview:true,
			                height: '100%',
			                rownumbers: true,
			                autoWidth: true,
			                caption: '<br/><br/>',
			                beforeSelectRow: function(rowid, e){
							    jQuery("#list").jqGrid('resetSelection');
							    return(true);
							}
			                
						})

            	$('#list').jqGrid('navGrid', '#pager', { add: false, edit: false, del: false, search: true, refresh: true });
				$('#list').setGridHeight(235,true);
				},
					error: function(x, e){             
						alert(x.readyState + " "+ x.status +" "+ e.msg);           
					}     
				}); 
				
				setTimeout(function() {$("#list").jqGrid('setGridParam',{datatype:'json'}); },50);


        });
    //]]>
    </script>

	<script type="text/javascript">

		function limpiarDatos() {
			var txts = document.getElementsByName("props");
			for ( var i = 0; i < txts.length; i++) {
				txts[i].value = "";
			}
		}
		
		function guardarDatos() {
			document.forms[1].action = "/agvWeb/admCat.do?method=agregar";
			document.forms[1].submit();
		}
		
		function actualizarDatos() {
			document.forms[1].action = "/agvWeb/admCat.do?method=actualizarCatBD";
			document.forms[1].submit();
		}
		
		function irAtras() {
			document.forms[1].action = "/agvWeb/admCat.do?method=irAtras";
			document.forms[1].submit();
		}
	
		function nuevoRegistro() {
			document.forms[0].action = "/agvWeb/adm.do?method=cfgCatalogos&nbCatalogo=proveedor";
			document.forms[0].submit();
		}


		
		$(function() {

			$('#s1').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});
			
			
			
			$('#s2').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#s3').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#s4').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#s5').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#s6').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#s7').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#s8').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d1').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});
			
			$('#d2').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d3').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d4').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d5').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d6').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d7').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d8').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d9').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d10').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d11').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d12').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d13').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

			$('#d14').numeric({
            	emptyValue: false,
				increment: 1,
				format: { decimalChar: '.' },
            	minValue: 0
        	});

				
			$('select#menuCatalogo0').selectmenu({style:'dropdown'});
			$('select#menuCatalogo1').selectmenu({style:'dropdown'});
			$('select#menuCatalogo2').selectmenu({style:'dropdown'});
			$('select#menuCatalogo3').selectmenu({style:'dropdown'});
			$('select#menuCatalogo4').selectmenu({style:'dropdown'});
			$('select#menuCatalogo5').selectmenu({style:'dropdown'});
			$('select#menuCatalogo6').selectmenu({style:'dropdown'});
			$('select#menuCatalogo7').selectmenu({style:'dropdown'});
			$('select#menuCatalogo8').selectmenu({style:'dropdown'});
			$('select#menuCatalogo9').selectmenu({style:'dropdown'});
			$('select#menuCatalogo10').selectmenu({style:'dropdown'});
			$('select#menuCatalogo11').selectmenu({style:'dropdown'});
			$('select#menuCatalogo12').selectmenu({style:'dropdown'});
			$('select#menuCatalogo13').selectmenu({style:'dropdown'});
			$('select#menuCatalogo14').selectmenu({style:'dropdown'});
			$('select#menuCatalogo15').selectmenu({style:'dropdown'});

			$( "#datepicker1" ).datepicker({
				showOn: "button",
				changeMonth: true,
				changeYear: true,
				buttonImage: "/agvWeb/images/icon_calendar.gif",
				dateFormat: "yy/mm/dd",
				dayNamesMin: ["Do","Lu","Ma","Mi","Ju","Vi","Sa"],
				monthNames: ["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],
				monthNamesShort: ["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],
				buttonImageOnly: true
			});
			
			$( "#datepicker2" ).datepicker({
				showOn: "button",
				changeMonth: true,
				changeYear: true,
				buttonImage: "/agvWeb/images/icon_calendar.gif",
				dateFormat: "yy/mm/dd",
				dayNamesMin: ["Do","Lu","Ma","Mi","Ju","Vi","Sa"],
				monthNames: ["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],
				monthNamesShort: ["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],
				buttonImageOnly: true
			});
			
			$( "#siguiente" ).button({
				text: true,
				icons: {
					primary: "ui-icon-arrowthick-1-e"
				}
			}).click(function() {
				document.forms[1].action = "/agvWeb/admCat.do?method=irAdelante";
				document.forms[1].submit();
			});
	
			$( "#confirmar" ).button({
				text: true,
				icons: {
					primary: "ui-icon-disk"
				}
			}).click(function() {
				<logic:present name="actualizarCatalogo">
					document.forms[1].action = "/agvWeb/admCat.do?method=actualizarCatBd";
					document.forms[1].submit();
				</logic:present>
				<logic:notPresent name="actualizarCatalogo">
					document.forms[1].action = "/agvWeb/admCat.do?method=insertarCatBd";
					document.forms[1].submit();
				</logic:notPresent>
			});
	
			$( "#anterior" ).button({
				text: true,
				icons: {
					primary: "ui-icon-arrowthick-1-w"
				}
			}).click(function() {
				document.forms[1].action = "/agvWeb/admCat.do?method=irAtras";
				document.forms[1].submit();
			});
			
		});

	</script>
</head>

<body>
	<html:form action="/admCat">
		<logic:notPresent name="buscaCatalogo">
			<table width="100%" height="100%">
				<tr>
					<td valign="top" height="100%">
						<table>
							<tr>
								<td>
									<logic:equal name="catalogoObj" property="stEstatus"
										value="no completado">
										<img src="/agvWeb/images/cross_small.png"
											style="vertical-align: middle;">
									</logic:equal>
									<logic:equal name="catalogoObj" property="stEstatus"
										value="completado">
										<img src="/agvWeb/images/tick-small.png"
											style="vertical-align: middle;">
									</logic:equal>
									<label class="lblContenido"
										title='<bean:write name="catalogoObj" property="stEstatus"/>'>
										<bean:write name="catalogoObj" property="nbTitulo" />
									</label>
								</td>
							</tr>
							<bean:define id="pasoAct" name="pasoActual"
								type="java.lang.String" scope="session" />
							<html:hidden property="nuSecuencia" value="<%=pasoAct%>" />
							<logic:iterate id="paso" name="catalogoObj" property="pasos">
								<tr>
									<logic:equal name="paso" property="nuSecuencia"
										value="<%=pasoAct%>">
										<td
											style="height: 35px; width: 270px; vertical-align: middle; padding-left: 30px; padding-top: 0px; background-image: url('/agvWeb/images/large_arrow.png');">
											<logic:equal name="paso" property="stEstatus"
												value="no completado">
												<img src="/agvWeb/images/cross_small.png"
													style="vertical-align: middle;">
											</logic:equal>
											<logic:equal name="paso" property="stEstatus"
												value="completado">
												<img src="/agvWeb/images/tick-small.png"
													style="vertical-align: middle;">
											</logic:equal>
											<logic:equal name="paso" property="stEstatus"
												value="en captura">
												<img src="/agvWeb/images/control_play.png"
													style="vertical-align: middle;">
											</logic:equal>
											<label style="vertical-align: middle;" class="lblContenido">
												Paso&nbsp;
												<bean:write name="paso" property="nuSecuencia" />
												.&nbsp;&nbsp;
												<bean:write name="paso" property="nbNombre" />
											</label>
										</td>
									</logic:equal>
									<logic:notEqual name="paso" property="nuSecuencia"
										value="<%=pasoAct%>">
										<td
											style="height: 35px; width: 270px; vertical-align: middle; padding-left: 30px; padding-top: 0px;">
											<logic:equal name="paso" property="stEstatus"
												value="no completado">
												<img src="/agvWeb/images/cross_small.png"
													style="vertical-align: middle;">
											</logic:equal>
											<logic:equal name="paso" property="stEstatus"
												value="completado">
												<img src="/agvWeb/images/tick-small.png"
													style="vertical-align: middle;">
											</logic:equal>
											<logic:equal name="paso" property="stEstatus"
												value="en captura">
												<img src="/agvWeb/images/control_play.png"
													style="vertical-align: middle;">
											</logic:equal>
											<label style="vertical-align: middle;" class="lblContenido">
												Paso&nbsp;
												<bean:write name="paso" property="nuSecuencia" />
												.&nbsp;&nbsp;
												<bean:write name="paso" property="nbNombre" />
											</label>
										</td>
									</logic:notEqual>
								</tr>
							</logic:iterate>
						</table>
					</td>
					<td width="1px">
						<img src="/agvWeb/images/divider.gif" height="100%" width="1px"
							style="vertical-align: middle;">
					</td>
					<td width="61%" height="100%"
						style="vertical-align: top; padding-left: 30px; padding-top: 5px;"
						align="left">
						<logic:notPresent name="catCompleto">
							<table align="left" width="100%" style="margin: 0px;"
								height="100%">
								<thead>
									<tr>
										<td colspan="2" align="left">
											<label class="lblContenido">
												Capture los siguientes datos
											</label>
										</td>
									</tr>
									<tr>
										<td align="left" colspan="2">
											<label class="lblRed">
												(*) Campo Requerido
											</label>
										</td>
									</tr>
									<tr>
										<td align="left" colspan="2">
											<html:messages id="msg" message="true">
												<label class="lblRed">
													Error:&nbsp;
													<bean:write name="msg" />
												</label>
											</html:messages>
										</td>
									</tr>
								</thead>
								<tbody>
									<tr>
										<td height="100%" width="100%" colspan="2">
											<div
												style="width: 100%; height: 90%; overflow-y: scroll; overflow-x: hidden;">
												<table align="center">
													<%
														Integer cont = new Integer(0);
																		Integer contDp = new Integer(1);
																		Integer contNs = new Integer(1);
																		Integer contNd = new Integer(1);
													%>
													<logic:iterate id="cat" name="catalogoObj"
														property="catalogos" indexId="catIndex" scope="session">
														<logic:equal
															value="<%=String
																	.valueOf(catIndex + 1)%>"
															name="pasoActual">
															<logic:iterate id="param" name="cat" property="params"
																type="com.agv.core.objectDomain.ParamCatalogo"
																scope="page">
																<tr class="odd">
																	<td align="right" style="height: 30px;">
																		<label class="lblContenidoSmall">
																			<bean:write name="param" property="nbLeyenda" />
																		</label>
																		<font style="color: red; font-size: 10px">*</font>&nbsp;
																	</td>
																	<td
																		style="height: 30px; width: 200px; vertical-align: middle;">
																		<logic:notEmpty name="param" scope="page"
																			property="arMenuSelect">
																			<html:select property="nbPropiedades"
																				styleId='<%="menuCatalogo"
																			+ (cont++)
																					.toString()%>'>
																				<logic:iterate id="arMenu" name="param" scope="page"
																					property="arMenuSelect"
																					type="com.agv.core.objectDomain.MenuSelect">
																					<html:option style="width: 200px;"
																						value="<%=arMenu
																								.getIdCampo()
																								.toString()%>"><%=arMenu
																								.getNbLeyenda()%></html:option>
																				</logic:iterate>
																			</html:select>
																		</logic:notEmpty>
																		<logic:empty name="param" scope="page"
																			property="arMenuSelect">

																			<logic:equal name="param" scope="page"
																				property="tpDato" value="cadena">
																				<html:text
																					maxlength="<%=param
																					.getLongitud()%>"
																					styleId="props"
																					value='<%=param
																					.getVlValue() != null ? param
																			.getVlValue()
																			: ""%>'
																					property="nbPropiedades"
																					styleClass="txtFrm ui-widget-content ui-corner-all" />
																			</logic:equal>
																			<logic:equal name="param" scope="page"
																				property="tpDato" value="entero">
																				<input type="text"
																					id="<%="s"
																			+ (contNs++)
																					.toString()%>"
																					value="0" name="nbPropiedades" />
																			</logic:equal>
																			<logic:equal name="param" scope="page"
																				property="tpDato" value="decimal">
																				<span style="height: 16px; vertical-align: top;">
																					<input type="text"
																						id="<%="d"
																			+ (contNd++)
																					.toString()%>"
																						value="0" name="nbPropiedades"
																						class="text ui-widget-content ui-corner-all" /> </span>
																			</logic:equal>
																			<logic:equal name="param" scope="page"
																				property="tpDato" value="fecha">
																				<input type="text"
																					id="<%="datepicker"
																			+ (contDp++)
																					.toString()%>"
																					name="nbPropiedades" readonly="readonly"
																					class="text ui-widget-content ui-corner-all" />
																			</logic:equal>

																			<logic:notEqual name="param" scope="page"
																				property="tpDato" value="entero">
																				<img src="/agvWeb/images/icon_info.gif"
																					style="cursor: pointer;"
																					alt='<bean:write name="param" scope="page" property="txValidacion"/>'>
																			</logic:notEqual>
																		</logic:empty>
																	</td>
																</tr>
															</logic:iterate>
														</logic:equal>
													</logic:iterate>
												</table>
											</div>
											<div align="right"
												style="height: 50px; padding-right: 130px; vertical-align: bottom; padding-top: 10px;">
												<logic:greaterThan name="pasoActual" value="1">
													<button id="anterior">
														anterior
													</button>
												</logic:greaterThan>
												<button id="siguiente">
													siguiente
												</button>
											</div>

										</td>
									</tr>
								</tbody>
							</table>
						</logic:notPresent>
						<logic:present name="catCompleto">
							<table id="hor-zebra" align="left" width="60%"
								style="margin: 0px;">
								<thead>
									<tr>
										<th colspan="2" align="left">
											Confirme la informaci&oacute;n capturada
										</th>
									</tr>
								</thead>
								<tbody>
									<tr>
										<td height="100%" width="100%" colspan="2">
											<div
												style="width: 100%; height: 220px; overflow-y: scroll; overflow-x: hidden;">
												<table align="center">
													<logic:iterate id="cat" name="catalogoObj"
														property="catalogos" indexId="catIndex" scope="session">
														<tr class="odd">
															<td align="left" colspan="2"
																style="height: 30px; font-weight: bold;">
																<bean:write name="cat" property="nbTitulo" />
															</td>
														</tr>
														<logic:iterate id="param" name="cat" property="params"
															type="com.agv.core.objectDomain.ParamCatalogo"
															scope="page">
															<tr class="odd">
																<td align="right" style="height: 30px;">
																	<bean:write name="param" property="nbLeyenda" />
																	:
																</td>
																<td style="height: 30px; width: 200px;">
																	<bean:write name="param" property="vlValue" />
																</td>
															</tr>
														</logic:iterate>
													</logic:iterate>
												</table>
											</div>
											<div align="right"
												style="height: 50px; padding-right: 43px; vertical-align: bottom; padding-top: 10px;">
												<logic:greaterEqual name="pasoActual" value="1">
													<button id="anterior">
														anterior
													</button>
												</logic:greaterEqual>
												<logic:notPresent name="catCompleto">
													<button id="siguiente">
														siguiente
													</button>
												</logic:notPresent>
												<logic:present name="catCompleto">
													<button id="confirmar">
														confirmar datos
													</button>
												</logic:present>
											</div>

										</td>
									</tr>
								</tbody>
							</table>
						</logic:present>

					</td>
				</tr>
			</table>
		</logic:notPresent>
		<logic:present name="buscaCatalogo">
			<div style="padding-top: 20px; width: 100%">

				<table id="list" style="width: 100%">
					<tbody>
						<tr>
							<td />
						</tr>
					</tbody>
				</table>
				<div id="pager"></div>


			</div>
		</logic:present>
	</html:form>
</body>
</html:html>
